In [2]:
s2="je m'appelle \"arwa\""
print(s2)
s2
je m'appelle "arwa"
Out[2]:
'je m\'appelle "arwa"'
In [4]:
s3='''il'fait beau.
je vais à l'école
je rentre.
'''
print(s3)
s3
il'fait beau.
je vais à l'école
je rentre.

Out[4]:
"il'fait beau.\nje vais à l'école\nje rentre.\n"
In [10]:
s="it's a good day"
# s[17]
s[-1]
s[-15]
s[-16]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Untitled-5.ipynb Cell 3 line 5
      <a href='vscode-notebook-cell:Untitled-5.ipynb?jupyter-notebook#W2sdW50aXRsZWQ%3D?line=2'>3</a> s[-1]
      <a href='vscode-notebook-cell:Untitled-5.ipynb?jupyter-notebook#W2sdW50aXRsZWQ%3D?line=3'>4</a> s[-15]
----> <a href='vscode-notebook-cell:Untitled-5.ipynb?jupyter-notebook#W2sdW50aXRsZWQ%3D?line=4'>5</a> s[-16]

IndexError: string index out of range
In [12]:
print(s3)
il'fait beau.
je vais à l'école
je rentre.

In [15]:
s3[13]
print(s3[13])
s3[13]

Out[15]:
'\n'
In [20]:
s1='it\'s a good day' # <\'> c'est une cote
s2="je m'appelle \"arwa\""
s1+s2
s2+s1
new_s=s1+'? '+s2+'!'
new_s
print(new_s)
it's a good day? je m'appelle "arwa"!
In [21]:
s
Out[21]:
"it's a good day"
In [24]:
s.index('o')
s.index('oo')
s.index('z')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Untitled-5.ipynb Cell 8 line 3
      <a href='vscode-notebook-cell:Untitled-5.ipynb?jupyter-notebook#X10sdW50aXRsZWQ%3D?line=0'>1</a> s.index('o')
      <a href='vscode-notebook-cell:Untitled-5.ipynb?jupyter-notebook#X10sdW50aXRsZWQ%3D?line=1'>2</a> s.index('oo')
----> <a href='vscode-notebook-cell:Untitled-5.ipynb?jupyter-notebook#X10sdW50aXRsZWQ%3D?line=2'>3</a> s.index('z')

ValueError: substring not found
In [26]:
s.count('a')
Out[26]:
2
In [28]:
s.find('o')
s.find('z')
Out[28]:
-1
In [29]:
l=[1,2,3,'bjr']
l.find(1)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Untitled-5.ipynb Cell 11 line 2
      <a href='vscode-notebook-cell:Untitled-5.ipynb?jupyter-notebook#X13sdW50aXRsZWQ%3D?line=0'>1</a> l=[1,2,3,'bjr']
----> <a href='vscode-notebook-cell:Untitled-5.ipynb?jupyter-notebook#X13sdW50aXRsZWQ%3D?line=1'>2</a> l.find(1)

AttributeError: 'list' object has no attribute 'find'
In [30]:
s
Out[30]:
"it's a good day"
In [40]:
len(s)
s[12:1000]
# s[a:b:1]
s[1000:1000000]
s[-1000:1000000]
s[-1000:-1]
s[a,b]==s[max(a,0),min(b,len(s))]
Out[40]:
"it's a good day"
In [53]:
s[::-2]
s[3:-1]
len(s[3:-1])
s[3:-1].upper()
# s[0]='I'
s='I'+s[1:]

s=s[:s.index('a')]+'A'+s[s.index('a')+1:]
In [55]:
s=s[:s.index('a')]+'A'+s[s.index('a')+1:]
In [59]:
list('fsdfsdfsdfsdfs')
list(range(1,99,7))
Out[59]:
[1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92]
In [61]:
l=[1,2,'bjr',True,(1,2)]
l[17]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Untitled-5.ipynb Cell 17 line 2
      <a href='vscode-notebook-cell:Untitled-5.ipynb?jupyter-notebook#X22sdW50aXRsZWQ%3D?line=0'>1</a> l=[1,2,'bjr',True,(1,2)]
----> <a href='vscode-notebook-cell:Untitled-5.ipynb?jupyter-notebook#X22sdW50aXRsZWQ%3D?line=1'>2</a> l[17]

IndexError: list index out of range
In [69]:
l=[1,2,'bjr',True,(1,2)]
l0=['a','b',-1j,2.5]
l1=['c',2]
l+[100]
l=l+[100]
l.append([20,20])
l.append('bjr')
l.extend([20,20])
l.extend('salut')
l
Out[69]:
[1,
 2,
 'bjr',
 True,
 (1, 2),
 100,
 [20, 20],
 'bjr',
 20,
 20,
 's',
 'a',
 'l',
 'u',
 't']
In [75]:
l=[1,2,'bjr',True,(1,2)]
# l.pop(0)
l.remove('bjr')
# l.pop(10)
l
Out[75]:
[1, 2, True, (1, 2)]
In [76]:
l=[1,2,'bjr',True,(1,2)]
In [81]:
l.reverse()
l
Out[81]:
[1, 2, 'bjr', True, (1, 2)]
In [82]:
l.sort()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Untitled-5.ipynb Cell 22 line 1
----> <a href='vscode-notebook-cell:Untitled-5.ipynb?jupyter-notebook#X30sdW50aXRsZWQ%3D?line=0'>1</a> l.sort()

TypeError: '<' not supported between instances of 'str' and 'int'